﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace PSE.Deployment.Util
{
    public static class EnumerableExtensions
    {
        public static IEnumerable<T> SelectDeep<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> selector)
        {
            if (source != null)
            {
                foreach (T item in source)
                {
                    yield return item;

                    foreach (T subItem in SelectDeep(selector(item), selector))
                    {
                        yield return subItem;
                    }
                }
            }
        }
    }
}